﻿package little.bunny.adapter;

import java.util.ArrayList;

import little.bunny.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class Test_List_Adapter extends BaseAdapter {
	//private Context context;
	//private String[][] Str1,LeftStr,RightStr;
	private LayoutInflater myInflater;
	private int Num1,XmlNum;
	private ArrayList<String[]> strVList;
	public Test_List_Adapter() {
		super();
	}

	
	
	

	public Test_List_Adapter(Context context,int num1, int num2, int xmlNum,
			ArrayList<String[]> strVList) {
		super();
		Num1 = num1;
		//Num2 = num2;
		XmlNum = xmlNum;
		this.strVList = strVList;
		this.Num1=num1;
		//this.Num2=num2;
		this.XmlNum=xmlNum;
		myInflater=LayoutInflater.from(context);
		for(int i=0;i<strVList.size();i++){
			System.out.println("适配器中的数据："+strVList.get(i)[0]);
		}
	}


	public int getCount() {
		// TODO Auto-generated method stub
		return strVList.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return strVList.get(arg0);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		ViewHolder holder = null;
		if (convertView == null) {
			// 自定义list_items为layout
			convertView = myInflater.inflate(XmlNum, null);
			/* 初始化holder */
			holder = new ViewHolder();
			 /*if(XmlNum==R.layout.nei_list_items){
				 holder.n_title = (TextView) convertView.findViewById(R.id.news_title);
				 holder.n_time = (TextView) convertView.findViewById(R.id.news_time);
			 }*/
			 if(XmlNum==R.layout.list_lists_items){
				 holder.shop_name=(TextView)convertView.findViewById(R.id.shops_title);
			 }
			/* if(XmlNum==R.layout.values_lists_items){
				 holder.price_t1=(TextView)convertView.findViewById(R.id.price_title1);
				 holder.price_v1=(TextView)convertView.findViewById(R.id.price_value1);
				 holder.price_t2=(TextView)convertView.findViewById(R.id.price_title2);
				 holder.price_v2=(TextView)convertView.findViewById(R.id.price_value2);
			 }*/
			//holder.n_title = (TextView) convertView.findViewById(R.id.news_title);
			//holder.n_time = (TextView) convertView.findViewById(R.id.news_time);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		// File f = new File(paths.get(position).toString());
		 /*if(XmlNum==R.layout.nei_list_items){
			 holder.n_title.setText(strVList.get(position)[Num1].toString());
			 //holder.n_title.setBackgroundColor(Color.argb(255, 0, 255, 0))
			 holder.n_time.setText(strVList.get(position)[Num2].toString());
		}*/
		if(XmlNum==R.layout.list_lists_items){
			holder.shop_name.setText(strVList.get(position)[Num1].toString());
		}
		/*if(XmlNum==R.layout.values_lists_items){
			 holder.price_t1.setText(LeftStr[position][Num1].toString());
			 holder.price_v1.setText(LeftStr[position][Num2].toString());
			 holder.price_t2.setText(RightStr[position][Num1].toString());
			 holder.price_v2.setText(RightStr[position][Num2].toString());
		 }*/
		return convertView;
		
	}
	
	/**
	 * 不单独写get set可以提高效率 class ViewHolder
	 * */
	private class ViewHolder {
		//TextView n_title;
		//TextView n_time;
		TextView shop_name;
		//TextView price_t1;
		//TextView price_v1;
		//TextView price_t2;
		//TextView price_v2;
		
	}
	public void addList(String[] str){
		strVList.add(str);
	}

}
